package com.gitee.wsl.compose.chart.xy

import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import com.gitee.wsl.common.ui.base.ColorOrBrush
import com.gitee.wsl.common.ui.base.toColorOrBrush
import com.gitee.wsl.common.ui.theme.local.Web
import com.gitee.wsl.common.ui.draw.type.Orient
import com.gitee.wsl.compose.chart.xy.axis.Axis
import com.gitee.wsl.mathematics.function.scale.FirstLastRange


@Composable
fun <X, Y> XYGraphScope<X, Y>.AxisX(
    orient: Orient = Orient.BOTTOM,
    scale: FirstLastRange<X, Float>,
    tickValues: List<X> = listOf(),
    tickSizeInner: Float = 6.0f,
    tickSizeOuter: Float = 6.0f,
    tickPadding: Float = 3.0f,
    axisStroke: ColorOrBrush? = Color.Web.black.toColorOrBrush(),
    axisStrokeWidth: Float? = 1.0f,
    tickStroke: ColorOrBrush? = Color.Web.black.toColorOrBrush(),
    tickStrokeWidth: Float? = 1.0f,
    fontSize: Float = 12.0f,
    fontColor: ColorOrBrush? = Color.Web.black.toColorOrBrush(),
    fontFamily: FontFamily = FontFamily.SansSerif,
    fontWeight: FontWeight = FontWeight.Normal,
    fontStyle: FontStyle = FontStyle.Normal,
    tickFormat: (X) -> String = { n: X -> n.toString() }
) = Axis(orient,
    scale,
    tickValues,
    tickSizeInner,
    tickSizeOuter,
    tickPadding,
    axisStroke,
    axisStrokeWidth,
    tickStroke,
    tickStrokeWidth,
    fontSize,
    fontColor,
    fontFamily,
    fontWeight,
    fontStyle,
    tickFormat
)

@Composable
fun <X, Y> XYGraphScope<X, Y>.AxisY(
    orient: Orient = Orient.LEFT,
    scale: FirstLastRange<Y, Float>,
    tickValues: List<Y> = listOf(),
    tickSizeInner: Float = 6.0f,
    tickSizeOuter: Float = 6.0f,
    tickPadding: Float = 3.0f,
    axisStroke: ColorOrBrush? = Color.Web.black.toColorOrBrush(),
    axisStrokeWidth: Float? = 1.0f,
    tickStroke: ColorOrBrush? = Color.Web.black.toColorOrBrush(),
    tickStrokeWidth: Float? = 1.0f,
    fontSize: Float = 12.0f,
    fontColor: ColorOrBrush? = Color.Web.black.toColorOrBrush(),
    fontFamily: FontFamily = FontFamily.SansSerif,
    fontWeight: FontWeight = FontWeight.Normal,
    fontStyle: FontStyle = FontStyle.Normal,
    tickFormat: (Y) -> String = { n: Y -> n.toString() }
) = Axis(orient,
    scale,
    tickValues,
    tickSizeInner,
    tickSizeOuter,
    tickPadding,
    axisStroke,
    axisStrokeWidth,
    tickStroke,
    tickStrokeWidth,
    fontSize,
    fontColor,
    fontFamily,
    fontWeight,
    fontStyle,
    tickFormat
)